home *** CD-ROM | disk | FTP | other *** search
- #define C
-
- #if 1
- #define SLOW
- #endif
-
- #ifdef __GNUC__
- #include <osbind.h>
- #else
- #include <tos.h>
- #endif
- #include <linea.h>
- #include <string.h>
- #include <stdio.h>
-
- #ifndef C
- extern "C" {
- #endif
-
- #ifdef __GNUC__
- void debit4plane(char *, short, short, short, short *, short);
- void debitplane(char *, short, short, short, short *, short);
- #endif
-
- #ifndef C
- }
- #endif
-
- #ifndef SLOW
- char vgabuf[64000];
- #endif
-
- long Scr_Offtop;
- long Scr_Offbot;
- long Scr_Size;
- char *_Scrn; /* Screen buffers */
-
- int v_x_max;
- int v_y_max;
- int vplanes = 0;
- int vwrap;
-
- void init_sc(void)
- {
- long phy, log;
-
- #ifdef __GNUC__
- linea0();
- v_x_max = V_X_MAX;
- v_y_max = V_Y_MAX;
- vplanes = VPLANES;
- vwrap = VWRAP;
- #else
- linea_init();
- v_x_max = Vdiesc->v_rez_hz; /* Not as in help documentation! */
- v_y_max = Vdiesc->v_rez_vt; /* Not as in help documentation! */
- vplanes = Linea->v_planes;
- vwrap = Linea->v_lin_wr;
- #endif
-
- /*
- * Get screen parameters, insure multiple of 256 bytes
- */
-
- phy = (long)Physbase();
- log = (long)Logbase();
- Scr_Offtop = (long)log-phy;
- Scr_Size = (long)vwrap * (long)v_y_max + Scr_Offtop;
- Scr_Offbot = ((Scr_Size + 255) & 0xffffff00L) - Scr_Size;
- if (Scr_Offtop)
- Scr_Offbot += 256;
- Scr_Size += Scr_Offbot;
-
- _Scrn = (char *)phy;
- }
-
- void c2p(char *buf, int w_area, int h_area)
- {
-
- /*
- * Show image in colour.
- */
-
- long yoffset, rowoffset;
- short x, y;
- short *screen, *wordpos;
- unsigned short q, pix;
- char *p;
-
- if (vplanes == 0)
- init_sc();
-
- #ifdef SLOW
- screen = (short *)_Scrn;
- #else
- screen = (short *)vgabuf;
- #endif
-
- /*
- * yoffset positions us into the screen which is an int array.
- */
-
- #ifdef SLOW
- yoffset = Scr_Offtop >> 1;
- #else
- yoffset = 0;
- #endif
-
- #ifdef __GNUC__
- if (vplanes == 4) {
- debit4plane(buf, w_area, w_area, h_area,
- &screen[yoffset], vwrap);
- #if 0
- return;
- #endif
- } else if (vplanes == 8) {
- debitplane(buf, w_area, w_area, h_area,
- &screen[yoffset], vwrap);
- #if 0
- return;
- #endif
- } else {
- #endif
- rowoffset = 0;
-
- /*
- * Loop over all rows in image
- */
-
- for (y = 0;y < h_area;y++) {
- /*
- * Set ptr to this pixel row
- */
-
- p = buf + rowoffset;
- wordpos = &screen[yoffset]; /* + vpanes - 1 ? */
-
- /*
- * Loop over all pixels in the row
- */
-
- #ifdef SLOW
- memset(wordpos, 0, vwrap);
- #else
- memset(wordpos, 0, 320 / 2);
- #endif
-
- pix = 0x8000;
- for (x = w_area;x > 0;x--) {
- q = *p++;
- if (q & 0x04)
- wordpos[2] |= pix;
- if (q & 0x08)
- wordpos[3] |= pix;
- if (q & 0x02)
- wordpos[1] |= pix;
- if (q & 0x01)
- wordpos[0] |= pix;
-
- if (!(pix >>= 1)) {
- wordpos += vplanes;
- pix = 0x8000;
- }
- }
-
- /*
- * Get ready for next row by incrementing offset into
- * the screens.
- */
-
- #ifdef SLOW
- yoffset += vwrap >> 1;
- #else
- yoffset += (320 / 2) >> 1;
- #endif
- rowoffset += w_area;
- }
- #ifdef __GNUC__
- }
- #endif
- #ifndef SLOW
- screen = (short *)_Scrn;
- yoffset = Scr_Offtop >> 1;
- rowoffset = 0;
- for(y = 0;y < h_area;y++) {
- memmove(&screen[yoffset], &vgabuf[rowoffset], 320 / 2);
- yoffset += vwrap >> 1;
- rowoffset += 320 / 2;
- }
- #endif
- }
-